Rework #770 to properly fix #749

The receiver for the const_defined?() was incorrect, and modifying the
whole line would render the definition of a constant *::Drop to be
omitted when *Drop was already defined.

Akinori MUSHA 10 years ago
parent
commit
cfe8482c0d
1 changed files with 6 additions and 1 deletions
  1. 6 1
      app/concerns/liquid_droppable.rb

+ 6 - 1
app/concerns/liquid_droppable.rb

@@ -21,7 +21,12 @@ module LiquidDroppable
21 21
   end
22 22
 
23 23
   included do
24
-    const_set :Drop, Kernel.const_set("#{name}Drop", Class.new(Drop)) unless const_defined?("#{name}Drop")
24
+    const_set :Drop,
25
+              if Kernel.const_defined?(drop_name = "#{name}Drop")
26
+                Kernel.const_get(drop_name)
27
+              else
28
+                Kernel.const_set(drop_name, Class.new(Drop))
29
+              end
25 30
   end
26 31
 
27 32
   def to_liquid